class calculateUtilService:

    # 流量库容转换系数
    def __init__(
            self,
            qv: float = 24 * 3600 / 1e8):
        self.qv = qv

    def getV1(self, inflow, outflow, flowWdrl, v0):
        return (inflow - outflow - flowWdrl) * self.qv + v0

    def getQout(self, inflow, flowWdrl, v0, v1):
        return inflow - flowWdrl - (v1 - v0) / self.qv

    def getQavl(self, inflow, outflow, v0, vMin):
        return (self.getV1(inflow, outflow, 0, v0) - vMin) / self.qv

    def getvMax(self, s, t):
        if 120 <= t <= 149:
            return s.getvMax() - (s.getvMax() - s.getvFlood()) * (t - 119) / 30.0
        elif 150 <= t <= 272:
            return s.getvFlood()
        elif 273 <= t <= 302:
            return s.getvFlood() + (s.getvMax() - s.getvFlood()) * (t - 272) / 30.0
        else:
            return s.getvMax()

